package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import pojo.Manager;
import pojo.RoomDto;

public class QueryMoneyDao {
	public QueryMoneyDao(){
		
	}
	public List<RoomDto>  queryRoomByNum(String roomNum){
		ConnectDao connectDao = new ConnectDao();
		List<RoomDto> list = new ArrayList<RoomDto> ();
		String sql = "SELECT *FROM room WHERE roomNum = '"+roomNum+"'";
		try{
			ResultSet rs = connectDao.stat.executeQuery(sql);
			while(rs.next()){
				RoomDto room = new RoomDto();
				room.roomNum = rs.getString("roomNum");
				room.area = rs.getString("area");
				room.roomType = rs.getString("roomType");
				room.money = rs.getString("money");
				room.status = rs.getString("status");
				System.out.println("room.status"+room.status);
				list.add(room);
				
			}
		}catch(SQLException e){
			e.printStackTrace();
			connectDao.closeConnect();
			return null;
		}
		connectDao.closeConnect();
		return list;
	}
	
	public List<String>  queryRateByMoney(String money){
		ConnectDao connectDao = new ConnectDao();
		List<String> list = new ArrayList<String> ();
		String sql = "SELECT prepay FROM rate WHERE money = '"+money+"'";
		try{
			ResultSet rs = connectDao.stat.executeQuery(sql);
			while(rs.next()){
				String prePay = rs.getString("prePay");
				list.add(prePay);
				
			}
		}catch(SQLException e){
			e.printStackTrace();
			connectDao.closeConnect();
			return null;
		}
		connectDao.closeConnect();
		return list;
	}
}
